package com.ruoyi.web.abstracts;

import com.ruoyi.web.domain.dto.ArticleRequestDTO;
import com.ruoyi.web.enums.ArticleTypeEnum;
import com.ruoyi.web.factory.StrategyFactory;
import com.ruoyi.web.service.StrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
public abstract class BaseStrategyService implements StrategyService {

    @Autowired
    private StrategyFactory strategyFactory;

    @PostConstruct
    public void init(){
        strategyFactory.register(getType(),this);
    }

    protected abstract ArticleTypeEnum getType();

    public abstract void doSomeThing(ArticleRequestDTO dto);

    public abstract void validate();

}
